<?php
class TableMaker
{
	private $arr_columns;
	private $arr_rows;
	private $arr_columnContents;
	
	public function __construct($arr_columns, $arr_rows)
	{
		$this->arr_columns = $arr_columns;
		$this->arr_rows = $arr_rows;
		$this->arr_columnContents = array();
	}
	
	public function getHtml()
	{
		$s_htmlTable = '<table>';
		$s_htmlTable .= $this->makeHtmlTableHead();
		$s_htmlTable .= $this->makeHtmlTableBody();
		$s_htmlTable .= '</table>';
		
		return $s_htmlTable;
	}
	
	public function getColumnContent($s_columnName)
	{
		return $this->arr_columnContents[$s_columnName];
	}
	
	private function makeHtmlTableHead()
	{
		$s_htmlTableHead = '<thead>';
		$s_htmlTableHead .= '<tr>';
		foreach($this->arr_columns as $s_column){
			$s_htmlTableHead .= '<th>' . $s_column . '</th>';
			$this->arr_columnContents[$s_column] = array();
		}
		$s_htmlTableHead .= '</tr>';
		$s_htmlTableHead .= '</thead>';
		return $s_htmlTableHead;
	}
	
	private function makeHtmlTableBody()
	{
		$s_htmlTableBody = '<tbody>';
		foreach($this->arr_rows as $arr_csvRow){
			$s_htmlTableBody .= '<tr>';
			foreach($arr_csvRow as $s_key=> $s_value){
				$s_htmlTableBody .= '<td>' . $s_value . '</td>';
				//$this->arr_columnContents[$s_key][] = $s_value;
				//print_r($this->arr_columnContents[$s_key]);
				array_push($this->arr_columnContents[$s_key], $s_value);
			}
			$s_htmlTableBody .= '</tr>';
		}
		$s_htmlTableBody .= '</tbody>';
		return $s_htmlTableBody;
	}
}